package net.siufung.market.base.user.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import net.siufung.core.model.EnumsVo;
import net.siufung.core.model.IEnum;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 陈建峰
 * @since 2022/8/4 10:33 上午
 */
@ToString
@AllArgsConstructor
public enum UserSexes implements IEnum<String> {

    /**
     * 女
     */
    WOMAN("0", "女"),
    /**
     * 男
     */
    MAN("1", "男"),
    /**
     * 未知
     */
    UNKNOWN("2", "未知");

    @Getter
    @Setter
    private String value;

    @Getter
    @Setter
    private String desc;

    public static UserSexes get(String value) {
        return IEnum.get(UserSexes.class,
                enums -> enums.getValue().equals(value));
    }

    public static String getDesc(String value) {
        return IEnum.getDesc(UserSexes.class,
                enums -> enums.getValue().equals(value));
    }

    public static List<EnumsVo> getList(){
        return IEnum.findList(UserSexes.class).stream()
                .map(element -> new EnumsVo(element.getValue(), element.getDesc()))
                .collect(Collectors.toList());
    }

}
